'''
@Project ：pythonApiTest 
@File    ：smart_assert.py
@IDE     ：PyCharm 
@Author  ：胡文
@Date    ：2025/2/28 上午9:40 
'''

def smart_assert(expected, actual):
    """智能断言，支持类型匹配和模糊匹配"""
    if isinstance(expected, dict):
        for k, v in expected.items():
            assert k in actual, f"缺少字段 {k}"
            smart_assert(v, actual[k])
    elif isinstance(expected, list):
        assert len(expected) == len(actual)
        for i, item in enumerate(expected):
            smart_assert(item, actual[i])
    else:
        assert expected == actual